package 力扣日常刷题.木23一月.第01天301;

import 力扣日常刷题.TreeNode;

/**
 * @author 帅小伙
 * @date 2022/3/1
 * @description
 */
public class Demo09对称的二叉树 {


    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;
        return isSymmetric(root, root);
    }

    public boolean isSymmetric(TreeNode left, TreeNode right) {
        if (left == null && right == null) return true;
        if(left == null || right == null) return false;
        if(left.val != right.val) return false;
        // 右右  左左
        return isSymmetric(left.left,right.right) && isSymmetric(left.right,right.left);
    }

}
